<template>
    <div class="navigator">
        <div class="logo" @click="handleLogoClick">
            <span class="logo-img"></span>
            <span class="logo-title"></span>
        </div>
    </div>
    <div class="shell">
        <div>
            <vue-particles id="tsparticles" :particlesLoaded="particlesLoaded" :options="{
                background: {
                    color: {
                        value: '#87CEFA'
                    }
                },
                fpsLimit: 120,
                interactivity: {
                    events: {
                        onClick: {
                            enable: true,
                            mode: 'push'
                        },
                        onHover: {
                            enable: true,
                            mode: 'repulse'
                        },
                    },
                    modes: {
                        bubble: {
                            distance: 400,
                            duration: 2,
                            opacity: 0.8,
                            size: 40
                        },
                        push: {
                            quantity: 4
                        },
                        repulse: {
                            distance: 200,
                            duration: 0.4
                        }
                    }
                },
                particles: {
                    color: {
                        value: '#ffffff'//#87CEFA
                    },
                    links: {
                        color: '#fff',
                        distance: 150,
                        enable: true,
                        opacity: 0.5,
                        width: 1
                    },
                    move: {
                        direction: 'none',
                        enable: true,
                        outModes: 'bounce',
                        random: false,
                        speed: 2,
                        straight: false
                    },
                    number: {
                        density: {
                            enable: true,
                        },
                        value: 120
                    },
                    opacity: {
                        value: 0.5
                    },
                    shape: {
                        type: 'circle'
                    },
                    size: {
                        value: { min: 1, max: 5 }
                    }
                },
                detectRetina: true
            }" />
        </div>
        <div class="container a-container" id="a-container">
            <form action="" method="" class="form" id="a-form">
                <h2 class="form_title title">创建账号</h2>
                <div class="form_icons">
                    <div class="icon-box">
                        <i class="iconfont icon-QQ"></i>
                    </div>
                    <div class="icon-box">
                        <i class="iconfont icon-VX"></i>
                    </div>
                    <div class="icon-box">
                        <i class="iconfont icon-MB"></i>
                    </div>
                </div>
                <span class="form-span">选择注册方式或电子邮箱注册</span>
                <input type="text" class="form_input" placeholder="Username">
                <input type="text" class="form_input" placeholder="Email">
                <input type="text" class="form_input" placeholder="Password">
                <button class="form_button button submit" @click="register">SIGN UP</button>
            </form>
        </div>

        <div class="container b-container" id="b-container">
            <form action="" method="" class="form" id="b-form">
                <h2 class="form_title title">登入账号</h2>
                <div class="form_icons">
                    <div class="icon-box">
                        <i class="iconfont icon-QQ"></i>
                    </div>
                    <div class="icon-box">
                        <i class="iconfont icon-VX"></i>
                    </div>
                    <div class="icon-box">
                        <i class="iconfont icon-MB"></i>
                    </div>
                </div>
                <span class="form-span">选择登录方式或电子邮箱登录</span>
                <input type="text" class="form_input" placeholder="Username">
                <input type="text" class="form_input" placeholder="Password">
                <a class="form_link" @click="handleForgetPwd">忘记密码？</a>
                <button class="form_button button submit" @click="login">SIGN IN</button>
            </form>
        </div>

        <div class="switch" id="switch-cnt">
            <div class="switch_circle"></div>
            <div class="switch_circle switch_circle-t"></div>
            <div class="switch-container" id="switch-c1">
                <h2 class="switch_title title" style="letter-spacing:0;">Welcome Back ! </h2>
                <p class="switch_description">登入账号进入NKCN·Brain世界吧！</p>
                <button class="switch_button button switch-btn" @click="changeForm">SIGN IN</button>
            </div>

            <div class="switch-container is-hidden" id="switch-c2">
                <h2 class="switch_title title" style="letter-spacing:0;">New Friend ! </h2>
                <p class="switch_description">注册账号，成为会员，踏入奇妙旅途！</p>
                <button class="switch_button button switch-btn" @click="changeForm">SIGN UP</button>
            </div>
        </div>
    </div>
</template>

<script>
import { get, post } from '@/api';

export default {
    name: 'Login',
    components: {
    },
    mounted() {
        // 组件挂载后调用函数
        this.particlesLoaded(this.$el);
        this.changeForm();
    },
    methods: {
        handleLogoClick() {
            this.$router.push('/');
        },
        // 定义一个异步函数
        async particlesLoaded(container) {
            console.log("Particles container loaded", container);
            // 你可以在这里执行更多异步操作
        },
        changeForm(e) {
            let switchCtn = document.querySelector("#switch-cnt");
            let switchC1 = document.querySelector("#switch-c1");
            let switchC2 = document.querySelector("#switch-c2");
            let switchCircle = document.querySelectorAll(".switch_circle");
            let aContainer = document.querySelector("#a-container");
            let bContainer = document.querySelector("#b-container");

            switchCtn.classList.add("is-gx");
            setTimeout(() => {
                switchCtn.classList.remove("is-gx");
            }, 1500);

            switchCtn.classList.toggle("is-txr");

            switchCircle[0].classList.toggle("is-txr");
            switchCircle[1].classList.toggle("is-txr");

            switchC1.classList.toggle("is-hidden");
            switchC2.classList.toggle("is-hidden");
            aContainer.classList.toggle("is-txl");
            bContainer.classList.toggle("is-txl");
            bContainer.classList.toggle("is-z");
        },
        login() {
            // this.$message.success('点击登录');
            this.$router.push('/main/library');
        },
        register() {
            this.$message.error('点击注册');
        },
        handleForgetPwd() {
            this.$message.error('忘记密码');
        },
    }
}
</script>
<style scoped>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    width: 100%;
    height: 95vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    background-color: #ecf0f3;
    color: #a0a5a8;
}

.navigator {
    width: 100vw;
    height: 10vh;
    margin: 0;
    padding: 0;
    display: flex;
    background: none;
}

.logo {
    width: 22vw;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 10px;
    padding-left: 2vw;
    cursor: pointer;
    z-index: 2;
}

.logo-img {
    width: 50%;
    height: 100%;
    background-image: url('@/assets/img/home/logo_img.png');
    background-size: contain;
    background-repeat: no-repeat;
}

.logo-title {
    width: 50vw;
    height: 6vh;
    background-image: url('@/assets/img/home/logo_title.png');
    background-size: contain;
    background-repeat: no-repeat;
}

.shell {
    position: relative;
    width: 1000px;
    min-width: 1000px;
    min-height: 600px;
    height: 600px;
    padding: 25px;
    background-color: #ecf0f3;
    box-shadow: 10px 10px 10px #d1d9e6, -10px -10px 10px #f9f9f9;
    border-radius: 12px;
    overflow: hidden;
    margin: auto;
    margin-top: 50px;
}

@media(max-width:1200px) {
    .shell {
        transform: scale(0.7);
    }
}

@media(max-width:1000px) {
    .shell {
        transform: scale(0.6);
    }
}

@media(max-width:800px) {
    .shell {
        transform: scale(0.5);
    }
}

@media(max-width:600px) {
    .shell {
        transform: scale(0.4);
    }
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    width: 600px;
    height: 100%;
    padding: 25px;
    background-color: #ecf0f3;
    transition: 1.25s;
}

.form {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    width: 100%;
    height: 100%;
}


.form_icons {
    display: flex;
    height: 72px;
    width: auto;
    min-width: 300px;
    justify-content: center;
    /* flex主轴对齐 */
    align-items: center;
    /* flex交叉轴对齐 */
}

.icon-box {
    margin: 0 10px;
    border: rgba(0, 0, 0, 0.5) 2px solid;
    border-radius: 50%;
    opacity: 0.5;
    transition: 0.3s;
    height: 48px;
    width: 48px;

    position: relative;
}


.icon-box:hover {
    opacity: 1;
    cursor: pointer;
    transform: scale(1.1);
}

.form_input {
    width: 350px;
    height: 40px;
    margin: 4px 0;
    padding-left: 25px;
    font-size: 13px;
    letter-spacing: 0.15px;
    border: none;
    outline: none;
    background-color: #ecf0f3;
    transition: 0.25s ease;
    border-radius: 8px;
    box-shadow: inset 2px 2px 4px #d1d9e6, inset -2px -2px 4px #f9f9f9;
}

.form_input:focus {
    box-shadow: inset 4px 4px 4px #d1d9e6, inset -4px -4px -4px #f9f9f9;
}

.form-span {
    margin-top: 30px;
    margin-bottom: 12px;
}

.form_link {
    color: #181818;
    font-size: 15px;
    margin-top: 25px;
    border-bottom: 1px solid #a0a5a8;
    line-height: 2;
    cursor: pointer;
}

.title {
    font-size: 26px;
    font-weight: 900;
    color: #181818;
    line-height: 3;
    letter-spacing: 5px;
}

.description {
    font-size: 14px;
    letter-spacing: 0.25px;
    text-align: center;
    line-height: 1.6;
}

.button {
    width: 180px;
    height: 50px;
    border-radius: 25px;
    margin-top: 50px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1.15px;
    background-color: #4B70E2;
    color: #f9f9f9;
    box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #f9f9f9;
    border: none;
    outline: none;
}

.a-container {
    z-index: 100;
    left: calc(100% - 600px);
}

.b-container {
    left: calc(100% - 600px);
    z-index: 0;
}

.switch {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 400px;
    padding: 40px;
    z-index: 200;
    transition: 1.25s;
    background-color: #ecf0f3;
    overflow: hidden;
    box-shadow: 4px 4px 10px #d1d9e6, -4px -4px 10px #d1d9e6;
}

.switch_circle {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background-color: #ecf0f3;
    box-shadow: inset 8px 8px 12px #b8bec7, inset -8px -8px 12px #fff;
    bottom: -60%;
    left: -60%;
    transition: 1.25s;
}

.switch_circle-t {
    top: -30%;
    left: 60%;
    width: 300px;
    height: 300px;
}

.switch-container {
    display: block;
    justify-content: center;
    align-items: center;
    flex-direction: absolute;
    width: 400px;
    padding: 20px 25px;
    transition: 1.25s;
}

.switch_button {
    margin-left: 40px;
    cursor: pointer;
}

.switch_button:hover,
.submit:hover {
    box-shadow: 6px 6px 10px #d1d9e6, -6px -6px 10px #f9f9f9;
    transform: scale(0.985);
    transition: 0.25s;
}

.switch_button:active,
.switch_button:focus {
    box-shadow: 2px 2px 6px #d1d9e6, -2px -2px 6px #f9f9f9;
    transform: scale(0.97);
    transition: 0.25s;
}

.switch_description {
    margin-top: 50px;
    font-size: 14px;
    align-content: left;
}

.is-txr {
    left: calc(100% - 400px);
    transition: 1.25s;
    transform-origin: left;
}

.is-txl {
    left: 0;
    transition: 1.25s;
    transform-origin: right;
}

.is-z {
    z-index: 200;
    transition: 1.25s;
}

.is-hidden {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    transition: 1.25s;
}

.is-gx {
    animation: is-gx 1.25s;
}

@keyframes is-gc {

    0%,
    10%,
    100% {
        width: 400px;
    }

    30%,
    50% {
        width: 500px;
    }
}

.icon-QQ {
    background-image: url("@/assets/img/login/qq.png");
    width: 32px;
    height: 32px;
    background-size: cover;
    display: inline-block;

    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.icon-VX {
    background-image: url("@/assets/img/login/vx.png");
    width: 32px;
    height: 32px;
    background-size: cover;
    display: inline-block;

    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.icon-MB {
    background-image: url("@/assets/img/login/mobile.png");
    width: 32px;
    height: 32px;
    background-size: cover;
    display: inline-block;

    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
</style>